package com.asp.mapper;

import com.asp.annotation.AutoFill;
import com.asp.dto.TopicClickDTO;
import com.asp.dto.TopicPageQueryDTO;
import com.asp.dto.TopicReplyClickDTO;
import com.asp.entity.Click;
import com.asp.entity.Topic;
import com.asp.entity.TopicDetail;
import com.asp.enumeration.OperationType;
import com.asp.vo.TopicPageQueryVO;
import com.asp.vo.TopicReplyPageQueryVO;
import com.github.pagehelper.Page;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

/**
 * author:          ndg
 * date:            2024/1/5
 */
@Mapper
public interface InteractMapper {

    @AutoFill(OperationType.INSERT)
    void insertTopic(Topic topic);

    Page<TopicPageQueryVO> pageQuery(TopicPageQueryDTO topicPageQueryDTO);

    Topic selectByTopicId(Integer topicId);

    @AutoFill(OperationType.INSERT)
    void insertTopicDetail(TopicDetail topicDetail);


    @Delete("delete from tb_topic where topic_id = #{topicId}")
    void deleteTopic(Integer topicId);


    /*删除主题细节*/
    @Delete("delete from tb_topic_detail where topic_id = #{topicId}")
    void deleteTopicDetailByTopicId(Integer topicId);

    Page<TopicReplyPageQueryVO> selectReplyByTopicId(Integer topicId, String userName);

    Click selectClickByUserNameAndTopicId(TopicClickDTO topicClickDTO);

    @AutoFill(OperationType.INSERT)
    void insertClick(Click c);

    void updateTopic(Integer topicId);

    @Delete("delete from tb_click where topic_id = #{topicId}")
    void deleteClickByTopicId(Integer topicId);

    Click selectClickByUserNameAndTopicDetailId(TopicReplyClickDTO topicReplyClickDTO);

    void updateTpoicDetail(Integer topicDetailId);

    @Select("select topic_detail_id, topic_id, user_name, content, create_time, click, update_time from tb_topic_detail where  topic_detail_id = #{topicDetailId}")
    TopicDetail selectTopicDetailByTopicDetailId(Integer topicDetailId);

    @Delete("delete from tb_topic_detail where topic_detail_id = #{topicDetailId}")
    void deleteTopicDetailByTopicDetailId(Integer topicDetailId);

    @Delete("delete from tb_click where topic_detail_id = #{topicDetailId}")
    void deleteClickByTopicDetailId(Integer topicDetailId);

    void deleteClickByTopicIdAndUserName(TopicClickDTO topicClickDTO);

    void deleteClickByTopicDetailIdAndUserName(TopicReplyClickDTO topicReplyClickDTO);
}
